package top.infopub.mgr.cap.web;

import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.infopub.mgr.cap.domain.CreditBalanceManagementDomain;
import top.infopub.mgr.cap.service.CreditBalanceManagementService;
import top.infopub.mgr.cap.vo.CreditBalanceManagementVo;
import top.infopub.mgr.common.page.ParamPage;
import top.infopub.mgr.common.vo.RspVo;
import top.infopub.model.cap.CreditBalanceManagement;
import top.infopub.tdp.sys.service.CodeGeneratorConfigService;

@Controller
@RequestMapping("/creditBalance")
public class CreditBalanceManagementController {

    @Autowired
    private CreditBalanceManagementService creditBalanceManagementService;

    @Autowired
    private CodeGeneratorConfigService codeGeneratorConfigService;


    @RequestMapping("/list")
    public String list() {
        return "cap/lay-creditBalanceManagement-list";
    }

    /**
     * 授信列表数据
     * @return
     */
    @RequestMapping("/queryDataByCondition")
    @ResponseBody
    public RspVo<CreditBalanceManagementDomain> queryDataByCondition(CreditBalanceManagementVo creditBalanceManagementVo,
                                                                     ParamPage paramPage) {
        Page<CreditBalanceManagementDomain> page = new Page<CreditBalanceManagementDomain>();
        page.setPageNum(paramPage.getPage());
        page.setPageSize(paramPage.getLimit());
        page = creditBalanceManagementService.selectByDomainWhere(page,creditBalanceManagementVo);
        return RspVo.getSuccessResponse(page.getTotal(), page.getResult());
    }

    /*新增*/
    @RequestMapping("/add")
    @ResponseBody
    public RspVo add(CreditBalanceManagement creditBalanceManagement){
        int add= creditBalanceManagementService.add(creditBalanceManagement);
        return RspVo.getSuccessResponse("保存成功");
    }
}
